import { useRef } from "react"

const useDebounce = (fn, delay) => {
    let timer = useRef(null)
    return ((...arg) => {
        clearTimeout(timer.current)
        timer.current = setTimeout(() => {
            fn(...arg)
        }, delay)
    })
}
export default useDebounce